#ifndef VOICE_H
#define VOICE_H

#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>
#include <QTableWidgetItem>
#include <QVector>
#include <QMediaPlayer>
#include <QAudioOutput>
#include <QAudioFormat>
#include "qmydatabase.h"
#include <QScroller>
#include <QTimer>

namespace Ui {
class voice;
}

struct musicInfo
{
    qlonglong id;
    QString name;
    QStringList artists;//歌手名
    QString album;//专辑名
    qlonglong duration;//歌曲的时长，单位为毫秒
};

struct STR
{
    QString id;
    QString name;
    QString artists;//歌手名
    QString album;//专辑名
    QString duration;//歌曲的时长，单位为毫秒
};

class voice : public QWidget
{
    int currentRow;
    Q_OBJECT

public:
    explicit voice(QWidget *parent = nullptr);
    ~voice();
    void parseJson(QByteArray & byteArr);
    // void parseJson1(QByteArray &byteArr);
    virtual void closeEvent(QCloseEvent *event);


    // int rowclick(int num);
public slots:
    void mylovefinished();

    void finishedSlot(QNetworkReply *reply);

    void on_pushButton_clicked();

    void on_tableWidget_cellDoubleClicked(int row, int column);

    void positionChangedSlot(qint64 position);

    void on_horizontalSlider_sliderMoved(int position);

    void on_horizontalSlider_sliderPressed();

    void on_horizontalSlider_sliderReleased();

    // QVector<musicInfo>  conversionVec();//

private slots:
    void on_voiceSlider_valueChanged(int value);

    //播放暂停键
    void on_pushButton_4_clicked();

    //下方喜欢按钮
    void on_pushButton_7_clicked();

    //我喜欢的按钮
    void on_pushButton_3_clicked();

    //下一首
    void on_pushButton_6_clicked();

    //上一首
    void on_pushButton_5_clicked();
    // void nextclick();


    void on_tableWidget_cellClicked(int row, int column)
    {
        currentRow = row;
    }

    void someOtherFunction() {
        qDebug() << "The current row is:" << currentRow;
    }
signals:
            void mylove();
private:
    Ui::voice *ui;
    QNetworkAccessManager * pManager;
    musicInfo playing;
    QVector<musicInfo> vMi;//存放搜索到的歌曲信息的数组容器
    QVector<musicInfo> vData;//存放搜索到的歌曲信息的数组容器
    QMediaPlayer * player;//媒体播放器
    QAudioOutput * audioOutput;//音频输出对象，可以调整音频参数，例如声音大小
    int currentIndex;//当前歌曲的下标
    MyDatabase *database;
};

#endif // VOICE_H
